/**
 * @project sky-take-out_1
 * @author MECHREVO
 * @date 2023/12/8 16:15:40
 * @version 1.0
 */
package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController("userShopController")
@Slf4j
@RequestMapping("/user/shop")
public class ShopController {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping("/status")
    @ApiOperation("获取店铺状态")
    public Result getStatus() {
        ValueOperations<String, Object> opsForValue = redisTemplate.opsForValue();
        Integer status = (Integer) opsForValue.get("SHOP_STATUS");
        if(Objects.isNull(status)){
            return Result.success(0);
        }
        return Result.success(status);
    }
}
